package com.study.study;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author study
 * @version 1.0
 * @date 2020/9/14 20:57
 */
class MyThread implements Runnable {
    @Override
    public void run() {

    }
}

class MyThread2 implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("***came in call method***");
        return 1024;
    }
}

public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable callable;
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread2());

        new Thread(futureTask, "A").start();

        Integer o = futureTask.get();
        System.out.println(o);

    }
}
